define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {


    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'vppz/followup/index' + location.search+'&ids='+Config.order_id,
                    add_url: 'vppz/followup/add?ids='+Config.order_id,
                    edit_url: 'vppz/followup/edit',
                    del_url: 'vppz/followup/del',
                    multi_url: 'vppz/followup/multi',
                    import_url: 'vppz/followup/import',
                    table: 'vppz_order_follow_up',
                }
            });

            var table = $("#table");

			var formatter_path=function(value,row,index){
				return '/vp_pz/pages/index/genjin?svid='+row.id;
			};

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'weigh',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'),searchable:false},
                        {field: 'follow_type', title: __('Followtype'), searchList: {"1":__('Followtype 1'),"2":__('Followtype 2'),"3":__('Followtype 3'),"4":__('Followtype 4'),"5":__('Followtype 5')}, formatter: Table.api.formatter.normal},
                        {field: 'admin.username', title: '操作人', operate: 'LIKE'},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime,visible: false},
						{field: 'follow_content', title: '跟进内容', operate: 'LIKE',width:300},
                        //{field: 'admin_id', title: __('Admin_id')},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        recyclebin: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    'dragsort_url': ''
                }
            });

            var table = $("#table");

            // 为表格绑定事件
            Table.api.bindevent(table);
        },

        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
